//
//  MineViewController.m
//  SeaChat
//
//  Created by 潘强 on 16/6/13.
//  Copyright © 2016年 潘强. All rights reserved.
//

#import "MineViewController.h"
#import "Login&RegViewController.h"
@interface MineViewController ()

@property(nonatomic,strong)UILabel *nameLabel;


@end

@implementation MineViewController
-(void)dealloc{
    [_nameLabel release];
    [super dealloc];
}
-(void)viewWillAppear:(BOOL)animated{


    //用户名label
    _nameLabel.text =  [EMClient sharedClient].currentUsername;


}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title  = @"我的";

    self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH/4, HEIGHT/9, WIDTH/2, 30)];
    _nameLabel.textColor = [UIColor blackColor];
    [self.view addSubview:_nameLabel];
    [_nameLabel release];


    UIButton *logout = [UIButton buttonWithType:UIButtonTypeCustom];
    logout.frame = CGRectMake(WIDTH/4 , HEIGHT/2 , WIDTH/2, 40);
    [logout setTitle:@"注销登录" forState:UIControlStateNormal];
    [logout setTintColor:[UIColor blackColor]];
    [logout setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [logout addTarget:self action:@selector(logoutAction) forControlEvents:UIControlEventTouchUpInside];
    logout.layer.borderWidth = 1;
    logout.layer.borderColor = [[UIColor blackColor]CGColor];
    [self.view addSubview:logout];
    // Do any additional setup after loading the view.
}
-(void)logoutAction{

    EMError *error = [[EMClient sharedClient] logout:YES];
    if (!error) {
        NSLog(@"退出成功");
        Login_RegViewController *Lvc = [[Login_RegViewController alloc]init];
        [self presentViewController:Lvc animated:1 completion:^{


        }];
        

    }
    


}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
